package com.vertx.starter;

import com.google.inject.Inject;
import io.vertx.core.Promise;
import io.vertx.ext.web.Router;
import lombok.extern.log4j.Log4j2;

@Log4j2
public class MainVerticleImpl extends MainVerticle {

    @Inject
    private RestRouter restRouter;

    @Override
    public void start(Promise<Void> startPromise) {
        Router router = restRouter.create(vertx);
        vertx.createHttpServer().requestHandler(router).listen(8888, http -> {
            if (http.succeeded()) {
                startPromise.complete();
                log.info("HTTP server started on port 8888");
            } else {
                startPromise.fail(http.cause());
            }
        });
    }

}
